<template>
  <h1>双向绑定</h1>
<!--  属性绑定 -->
  <input type="text" :value="un1">
  <p>回显数据:{{un1}}</p>
<!--  双向绑定 -->
  <input type="text" v-model="un2">
  <p>回显数据:{{un2}}</p>
  <hr>

  <input type="text" v-model="info">
  <button @click="console.log(info)">点击</button>
  <h3>用户登录</h3>
  <input type="text" placeholder="请输入用户名" v-model="user.name">
  <input type="text" placeholder="请输入密码" v-model="user.password">
  <br>
  性别:
  <input type="radio" name="gender" value="1" v-model="user.gender">男
  <input type="radio" name="gender" value="0" v-model="user.gender">女
  <button @click="login">登录</button>
</template>

<script setup>
import {ref} from "vue";

const un1 = ref("");
const un2 = ref("");
const info = ref('双向绑定');
const user = ref({
  name: "",
  password: "",
  gender: ""
});
const login = () => {
  console.log(user.value);
  console.log(user.value.name);
  console.log(user.value.password);
  console.log(user.value.gender);
}


</script>

<style scoped>

</style>